//引入封装的request
import request from '@/utils/request';
import type { ILoginForm, IInfoCallback, ILoginCallback, ResponseData, UpPassword } from './type';
//统一管理接口地址
enum Url {
  Login = '/admin/login',
  Info = '/admin/getinfo',
  LoginOut = '/admin/logout',
  ChangePassword = '/admin/updatepassword',
  Statistics1 = '/admin/statistics1',
  Statistics2 = '/admin/statistics2',
  Statistics3 = '/admin/statistics3'
}
enum DateType {
  //month近1个月、week近1周、hour近24小时
  month = 'month',
  week = 'week',
  hour = 'hour'
}
//统一请求
export const getLogin = (data: ILoginForm) => request.post<any, ILoginCallback>(Url.Login, data);
export const getInfo = () => request.post<any, IInfoCallback>(Url.Info);
export const getLoginOut = () => request.post<any, ResponseData>(Url.LoginOut);
export const changePasswordApi = (data: UpPassword) => request.post<any, ResponseData>(Url.ChangePassword, data);
//获取首页展示数据
export const getStatistics1 = () => request.get<any, ResponseData>(Url.Statistics1);
export const getStatistics2 = () => request.get<any, ResponseData>(Url.Statistics2);
//图表 数据
export const getStatistics3 = (type: DateType) => request.get<any, ResponseData>(`${Url.Statistics3}?type=` + type);
